//
//  NetworkTool.h
//  Kits
//
//  Created by MiaoYe on 15/6/28.
//  Copyright (c) 2015年 Azhuo. All rights reserved.
//  网络定义及一些工具方法

typedef void(^SuccessBlock)(id success);
typedef void(^FailedBlock)(id failed);
//接口定义
//http://api.magilit.com:50010
#define SERVER_KEY          @"http://api.magilit.com:50010"    //客户端服务器地址
#define SERVER_KEYW  @"http://121.43.111.133:50010"//外包公司客户端地址
#define URL_DOWN_SOFT_UPDATE @"http://www.magilit.com/app_update/ios.txt" //iOS 版本判断文件获取
#define URL_DOWN_SOFTDOWN @"http://www.pgyer.com/JYqg" //iOS 新版本地址 (蒲公英地址)
#define URL_DOWN_HARDWARE_UPDATE @"http://www.magilit.com/app_update/firmware.txt" //固件版本 判断文件获取地址（暂时用这个，后期会写接口）
#define URL_DOWN_HARDWAREDOWN @"http://www.magilit.com/app_update/update" // 固件版本前缀 后面的1.2.bin需要自己拼接   http://www.magilit.com/app_update/update1.2.bin



#define URL_MACRO(p) [NSString stringWithFormat:@"%@%@",SERVER_KEY,p]//
//手机验证
#define CHECK_PHONE        URL_MACRO(@"/Home/shoujyz")
//用户验证
#define HOME_YONGHUYZ        URL_MACRO(@"/Home/yonghuyz")
//注册
#define URL_REGIST              URL_MACRO(@"/Home/zhuce")

//第三方注册
#define URL_REGIST_ANOTHER              URL_MACRO(@"/Home/disanzhuce")

//获取验证码
#define GET_DOCTOR_CODE              URL_MACRO(@"/doctor/sendSmsCode")
//校验验证码
#define VERIFY_DOCTOR_CODE           URL_MACRO(@"/doctor/verifySmsCode")

//手机获取验证码
#define VERIFY_PHONE_CODE           URL_MACRO(@"/Home/shoujiyz")

//用户修改密码
#define USER_INFORMATION_UPDATE        URL_MACRO(@"/Home/yonghuxg")

//重置密码
#define RESET_PWD              URL_MACRO(@"/doctor/resetpwd")



//登陆
#define Login                    URL_MACRO(@"/Home/denglu")

//获取基本信息
#define GET_INFO                 URL_MACRO(@"/Home/fankui")

//我的好友
#define  FRIEND_LIST            URL_MACRO(@"/Home/wodehao")
//添加好友
#define  ADD_FRIEND            URL_MACRO(@"/Home/tianjiah") 

//好友详情
#define  FRIEND_DETAIL            URL_MACRO(@"/Home/haoyouxq")

//更新好友备注信息
#define FRIEND_UPDATE_NAME       URL_MACRO(@"/Home/gexingqm")

//更新软件版本
#define USER_VERSION   URL_MACRO(@"/Home/banbenx")

//好友Pk
#define HAOYOU_PK                 URL_MACRO(@"/Home/haoyouPK")

//设置基本信息
#define SET_INFO                 URL_MACRO(@"/Home/dengxing")

//注销
#define LOG_OUT                URL_MACRO(@"/doctor/logout")
//修改密码
#define UPDATE_PWD            URL_MACRO(@"/doctor/updatepwd")

//设置用户头像
#define USER_HEADIMAGE           URL_MACRO(@"/Home/huiyuantx")

//系统通知
#define SYSTEM_PUSH       URL_MACRO(@"/doctor/pushList")
//删除系统通知
#define SYSTEM_DELETE    URL_MACRO(@"/doctor/delPush")

//上传睡眠报告
#define HOME_SLEEP_SUBMIT    URL_MACRO(@"/Home/baogao")

//睡眠时间接口
#define HOME_SLEEP_TIME    URL_MACRO(@"/Home/shuimian")
//点击日历获取睡眠信息
#define HOME_DATE_DATA       URL_MACRO(@"/Home/degnlurq")

//（日历的）报告详情
#define HOME_CALENDAR     URL_MACRO(@"/Home/baogaoxq")
//用户帮助  Home/yonghubangz
#define USER_HELP     URL_MACRO(@"/Home/yonghubangz")

//分享数据接口
#define HOME_SHARE     URL_MACRO(@"/Home/fengxiang")

//获取服务器图片头部
#define PICTURE_HEAD     URL_MACRO(@"/up/")

//本地推送图片的链接，这边定义成宏
#define URL_SCORE_FORTY @"http://www.magilit.com/score_push/fb_0-40.png"
#define URL_SCORE_SIXTY @"http://www.magilit.com/score_push/fb_40-60.png"
#define URL_SCORE_SEVERTY @"http://www.magilit.com/score_push/fb_60-70.png"
#define URL_SCORE_EIGHTFIVE @"http://www.magilit.com/score_push/fb_70-85.png"
#define URL_SCORE_ONEHUNDRED @"http://www.magilit.com/score_push/fb_85-100.png"
//本地推送链接
#define URL_SCORE_FORTY_PUSH  @"http://www.magilit.com/score_push/0-40/"
#define URL_SCORE_SIXTY_PUSH  @"http://www.magilit.com/score_push/40-60/"
#define URL_SCORE_SEVERTY_PUSH  @"http://www.magilit.com/score_push/60-70/"
#define URL_SCORE_EIGHTFIVE_PUSH  @"http://www.magilit.com/score_push/70-85/"
#define URL_SCORE_ONEHUNDRED_PUSH  @"http://www.magilit.com/score_push/85-100/"


#import <Foundation/Foundation.h>
#import "AFNetworking.h"
@interface NetworkTool : NSObject
/*异步GET请求
 *
 *command:    请求命令
 *parameters: 请求参数
 *success:    请求成功回调
 *failed:     请求失败回调
 */
+ (void)getWithUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(SuccessBlock)success failed:(FailedBlock)failed;

/*上传图片
 *
 *command:    请求命令
 *Parameters: 请求参数，upfile为上传图片
 *url:        上传图片路径
 *返回值为bool型，yes：成功，no：失败
 */
+ (void)uploadImageWithUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(SuccessBlock)success failed:(FailedBlock)failed;

+ (void)getInfoWithUrl:(NSString *)url parameters:(NSDictionary *)parameters image:(UIImage *)image success:(SuccessBlock)success failed:(FailedBlock)failed;
//JSon解析
+ (id)toNSDictionary:(NSData *)jsonData;
+ (id)toArray:(NSData *)jsonData;

+ (UIColor *) colorWithHexString: (NSString *)color;
/*+ (NSString *)generateSignByParams:(NSDictionary *)params
                      commonParams:(NSDictionary *)commonParams;
+ (NSMutableDictionary *)commonParams;
*/
+(NSDictionary *)parseJSONStringToNSDictionary:(NSString *)JSONString;

+(NSMutableArray *)parseJSONStringToNSMutableArray:(NSString *)JSONString;
+ (BOOL)isMobileNumber:(NSString *)mobileNum;
//+ (NSString *)timeFormatted:(int)totalSeconds;
@end
